home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / OpenDoc / ProcessMap / $Utilities / FrameList.cpp next >
Encoding:
C/C++ Source or Header  |  1995-04-19  |  2.2 KB  |  102 lines  |  [TEXT/MPCC]

  1. /*
  2.     File:        FrameList.cpp
  3.     Contains:    Linked list of frames, for use by parts
  4.     Written by:    PartMaker
  5.  
  6.     Change History (most recent first):
  7.  
  8.     <3>    4/6/95    TÇ        Changed from FacetList to FrameList
  9.     <2>    3/8/95    JS        Updated to b1c13/c14
  10.     <1>    2/2/95    RA        first checked in
  11.     <0>    PartMaker source by Eric Soldan, Tantek Çelik, Jens Alfke, Reggie Adkins
  12. */
  13.  
  14. #ifndef _FRAMELIST_
  15. #include "FrameList.h"
  16. #endif
  17.  
  18. #ifndef _ODTYPES_
  19. #include <ODTypes.h>
  20. #endif
  21.  
  22. #ifdef applec
  23. #pragma segment ProcessMap
  24. #endif
  25.  
  26.  
  27. //========================================================================================
  28. // FrameLink
  29. //========================================================================================
  30.  
  31. FrameLink::FrameLink( )
  32. {
  33.     fFrame = kODNULL;
  34.     fPrev  = this;
  35.     fNext  = this;
  36. }
  37.  
  38. //----------------------------------------------------------------------------------------
  39.  
  40. FrameLink::FrameLink( ODFrame *frame, FrameLink *list )
  41. {
  42.     fFrame = frame;
  43.     fPrev  = list;
  44.     fNext  = list->fNext;
  45.     list->fNext  = this;
  46.     fNext->fPrev = this;
  47. }
  48.  
  49. //----------------------------------------------------------------------------------------
  50.  
  51. FrameLink::~FrameLink( )
  52. {
  53.     if ( fPrev )
  54.         fPrev->fNext = fNext;
  55.     if ( fNext )
  56.         fNext->fPrev = fPrev;
  57. }
  58.  
  59.  
  60. //========================================================================================
  61. // FrameLink
  62. //========================================================================================
  63.  
  64. FrameList::FrameList()
  65. {
  66.     fFrame = kODNULL;
  67.     fPrev = kODNULL;
  68.     fNext = this;
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72.  
  73. FrameList::~FrameList( )
  74. {
  75.     // Delete all links:
  76.     while ( fNext != this )
  77.         delete fNext;
  78. }
  79.  
  80. //----------------------------------------------------------------------------------------
  81.  
  82. void FrameList::Add( ODFrame *frame )
  83. {
  84.     new FrameLink(frame,this);
  85.     // The new link has already hooked itself into my chain so I don't need to
  86.     // remember it elsewhere.
  87. }
  88.  
  89. //----------------------------------------------------------------------------------------
  90.  
  91. void FrameList::Remove( ODFrame *frame )
  92. {
  93.     for (FrameLink* link = this->First(); link->Frame(); link = link->Next() ) {
  94.         if ( link->Frame() == frame ) {
  95.             delete link;
  96.             return;
  97.         }
  98.     }
  99. }
  100.  
  101.  
  102.